package cn.bugstack.test.domain.tag;

import org.junit.jupiter.api.Test;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class RedisPingTest {

    @Autowired
    private RedissonClient redissonClient;

    @Test
    public void testRedisConnection() {
        try {
            // 获取一个简单的字符串 key
            RBucket<String> bucket = redissonClient.getBucket("test_key");
            bucket.set("Hello, Redis!");
            String value = bucket.get();

            System.out.println("Redis 连接成功，读取到的值: " + value);
        } catch (Exception e) {
            System.err.println("Redis 连接失败！");
            e.printStackTrace();
        }
    }
}